<template>
  <div :style="{ left, top }" class="BIM3DReality" @click="handleClickShowLegend">
    <h3 class="title">BIM三维实景</h3>
    <ul class="mapTypeListBox">
      <li class="listItem" @click.stop="handleClickMapType(1)">
        <span>新禹河闸</span>
      </li>
      <li class="listItem" @click.stop="handleClickMapType(2)">
        <span>三友水库</span>
      </li>
      <li class="listItem" @click.stop="handleClickMapType(3)">
        <span>东方红水库</span>
      </li>
    </ul>
  </div>
</template>

<script lang="ts" setup>
  import { reactive, onUnmounted } from 'vue';
  import { setCamera } from '@/components/GlobalVideo';
  import { addPopUp } from '@/components/GlobalVideo/src/addPopUp';

  defineOptions({ name: 'BIM3DReality' });

  defineProps({
    left: {
      type: String,
      default: '-180px',
    },
    top: {
      type: String,
      default: '550px',
    },
  });

  const state = reactive({
    isShowMapTypeList: false,
    typeIndex: 1,
  });

  const handleClickShowLegend = () => {
    state.isShowMapTypeList = !state.isShowMapTypeList;
  };

  // 点击切换地图底图
  const handleClickMapType = (typeIndex = 1) => {
    setCamera(typeIndex + '');
    // const globalViewer = getGlobalViewer();
    // let position: Cartesian3;
    // if (typeIndex === 1) {
    //   position = Cartesian3.fromDegrees(118.986416, 32.267584);
    // } else if (typeIndex === 2) {
    //   position = Cartesian3.fromDegrees(119.00774, 32.38695);
    // } else {
    //   position = Cartesian3.fromDegrees(119.01505, 32.362079);
    // }
    // globalViewer.camera.flyToBoundingSphere(new BoundingSphere(position, 1000));
  };

  defineExpose({
    handleClickMapType,
  });

  onUnmounted(() => {
    fdapi.settings.setInteractiveMode(0);
    addPopUp('xyhz', false); //新禹河闸弹框
  });
</script>

<style lang="less" rel="stylesheet/less" scoped>
  .BIM3DReality {
    width: 182px;
    height: auto;
    padding: 6px 0px;
    background: rgba(0, 40, 81, 0.4);
    box-shadow: 0px 4px 6px 0px #03225917;
    border-radius: 0px;
    border: 2px solid;
    border-image: linear-gradient(
      135.24deg,
      rgba(6, 183, 253, 0.4) 29.26%,
      rgba(101, 217, 255, 0.8) 51.39%,
      rgba(6, 183, 253, 0.2) 76.35%
    );
    border-image-slice: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    cursor: pointer;
    user-select: none;
    position: absolute;

    h3.title {
      width: 100%;
      line-height: 30px;
      font-size: 18px;
      font-weight: bold;
      color: #fff;
      text-align: center;
    }

    .mapTypeListBox {
      display: flex;
      flex-direction: column;

      li.listItem {
        width: 168px;
        height: 54px;
        background: url(images/bg.png) no-repeat;
        background-size: 100% 100%;
        position: relative;
        margin-bottom: 6px;
        cursor: pointer;

        &:hover {
          opacity: 0.8;

          span {
            color: #fff;
            opacity: 1;
          }
        }

        span {
          font-size: 16px;
          color: rgba(180, 223, 255, 1);
          position: absolute;
          top: 14px;
          left: 66px;
        }
      }
    }
  }
</style>
